<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Generator</title>
        <script>
        function* test(){
            consoleLog();
            let res = yield 1;
            consoleLog();
            console.log(res);
            yield 2;
            consoleLog();
            yield 3;
            consoleLog();
            yield 4;
        }
        let gen = test();
        //Generator对象 迭代器对象
        console.log(gen);
        console.log(gen.next());
        console.log(gen.next(100));
        function consoleLog(){
            for(let i =1;i<11;i++){
                console.log(i);
            }
        }
    </script>
    </head>
    <body>

    </body>
</html>